package com.xintonghua.bussiness.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.xintonghua.base.utils.MyTimeUtils;
import com.xintonghua.bussiness.R;
import com.xintonghua.bussiness.base.SimpleBaseAdapter;
import com.xintonghua.bussiness.bean.RecodePersonBean;
import com.xintonghua.bussiness.util.MyUtils;

import java.util.List;

/**
 * 各种考勤记录的list适配
 * Created by dyj on 2018/3/31 0031.
 */

public class CheckInNextListAdapter extends SimpleBaseAdapter<RecodePersonBean> {
    private String type;

    public CheckInNextListAdapter(List<RecodePersonBean> list, Context context, String type) {
        super(list, context);
        this.type = type;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context)
                    .inflate(R.layout.adapter_check_in_next_list, viewGroup, false);
            holder.name = convertView.findViewById(R.id.adapterCheckInNextName);
            holder.phone = convertView.findViewById(R.id.adapterCheckInNextPhone);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        RecodePersonBean bean = mList.get(position);
        holder.name.setText(bean.getName());
        switch (type) {
            case "weidaka":
                holder.phone.setText("上午:未打卡" + "\n" + "下午:未打卡");
                break;
            case "zhengchang":
                holder.phone.setText("上午: " + bean.getEndTime() + "\n下午:" + bean.getEndTime());
                break;
            case "chidao":
                holder.phone.setText("上午:" + bean.getStartTime() + " \n" + "下午:" + bean.getEndTime());
                break;
            case "zaotui":
                holder.phone.setText("上午:" + bean.getStartTime() + " \n" + "下午:" + bean.getEndTime());
                break;
        }
        return convertView;
    }

    class ViewHolder {
        TextView name;
        TextView phone;
    }

}
